<!DOCTYPE html>
<html lang="UTF-8">
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="codeMirror/codemirror.css">
    <link rel="stylesheet" href="codeMirror/merge.css">
    <link rel="stylesheet" href="codeMirror/darcula.css">
    <link rel="stylesheet" href="codeMirror/base16-light.css">
    <link rel="stylesheet" href="codeMirror/base16-light.css">
    <link rel="stylesheet" href="codeMirror/dialog.css">
    
    <link href="../css/bootstrap-table.min.css" rel="stylesheet">
	<link href="../css/bootstrap-table-fixed-columns.min.css" rel="stylesheet">
    <link href="../css/bootstrap.min.css" rel="stylesheet">
	  <link href="../css/bootstrap-select.css" rel="stylesheet">
	  <link rel="stylesheet" href="../css/bootstrap-datetimepicker.min.css">
	  <link rel="stylesheet" href="../layui/css/layui.css">
	  <link rel="stylesheet" href="../css/JyyMain2.css">
    <style>
        .CodeMirror {
            line-height: 1.2;
        }
        .CodeMirror {
		    border: 1px solid #eee;
		    height: 700px;
		    /*min-height: 100px;*/
		}
		

        @media screen and (min-width: 1300px) {
            article {
                max-width: 1177px;
            }

            #nav {
                border-right: 499px solid transparent;
            }
        }

        span.clicky {
            cursor: pointer;
            background: #d70;
            color: white;
            padding: 0 3px;
            border-radius: 3px;
        }

        h2 {
            color: yellowgreen;
        }
        
        .CodeMirror-merge, .CodeMirror-merge .CodeMirror {
		    height: 500px;
		}
    </style>

</head>

<body>
<article>
    <!-- <input type="file" name="file" multiple="multiple" id="files" onchange="choosefile()" /> -->
	<div style="float: left;height: 40px;margin-bottom: 10px;padding: 15px 0px 0px 0px;">
   	<label class="col-sm-3 control-label" style="margin: 6px 10px 0 18px;width: 120px;text-align: right;padding: 0px;">更新原始dat文件：</label>
      	<div class="col-sm-4" style="width: 200px;padding: 0px;">
			<input class="form-control input-sm" style="height: 35px;" type="file" multiple="multiple" id="dat" accept=".dat" required name="dat" onchange="inportDat()">
       </div>
  	</div>
   	<div style="float: left;height: 40px;margin-bottom: 10px;padding: 15px 0px 0px 0px;">
    	<label class="col-sm-3 control-label" style="margin: 6px 10px 0 18px;width: 120px;text-align: right;padding: 0px;">选择模拟方案：</label>
       	<div class="col-sm-4" style="width: 200px;padding: 0px;">
        	<select id="simulaScheme" class="selectpicker show-tick form-control" data-size="8" data-live-search="true" onchange="intParams();">
            	<option value="">选择模拟方案</option>
            </select>
        </div>
   	</div>
   	<div style="float: left;height: 40px;width: 230px;margin-top: 10px;padding: 6px 0px 0px 0px;">
   			<label class="col-sm-3 control-label" style="margin: 6px 10px 0 18px;width: 42px;text-align: right;padding: 0px;">日期：</label>
			<div class='input-group date' id='date0' style="width: 136px;margin-left: 5px;float: left;">
			    <input type='text' class="form-control" readonly="readonly" onchange="intParams();" />
			    <span class="input-group-addon">
			        <span class="glyphicon glyphicon-calendar"></span>
			    </span>
			</div>
   	</div>
   	<div style="float: left;height: 40px;width: 230px;margin-top: 10px;padding: 6px 0px 0px 0px;">
			<label class="col-sm-3 control-label" style="margin: 6px 10px 0 18px;width: 42px;text-align: right;padding: 0px;">时刻：</label>
			<div style="width: 80px;float: left;margin-left: 5px;float: left;">
					
	         		<select id="time0" class="selectpicker show-tick form-control" data-size="6" onchange="intParams();" ></select>
			</div>
   	</div>
   	
   	
	   	<div class="col-md-12" style="float: left;height: 40px;width: 140px;margin-top: 10px;padding: 6px 0px 0px 0px;">
			  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="margin: 6px 10px 0 18px;text-align: right;">
			    <font color="red">*</font>负荷功率因数 <span class="caret"></span>
			  </button>
			  <div id='dataDiv1' class="dropdown-menu" style="width: 200px;margin: 6px 10px 0 18px;">
				 
			  </div>
	   	</div>
	   	<div class="col-md-12" style="float: left;height: 40px;width: 162px;margin-top: 10px;padding: 6px 0px 0px 0px;">
	   			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"  aria-haspopup="true" aria-expanded="false" style="margin: 6px 10px 0 18px;text-align: right;">
			    <font color="red">*</font>发电机机端电压 <span class="caret"></span>
			  </button>
			  <div id='dataDiv2' class="dropdown-menu" style="width: 200px;margin: 6px 10px 0 18px;">
				 
			  </div>
	   	</div>
	   	<div class="col-md-12" style="float: left;height: 40px;width: 168px;margin-top: 10px;padding: 6px 0px 0px 0px;">
	   			<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="margin: 6px 10px 0 18px;text-align: right;">
			    <font color="red">*</font>直流无功补偿系数 <span class="caret"></span>
			  </button>
			  <div class="dropdown-menu" style="width: 700px;margin: 6px 10px 0 18px;height: 356px;overflow: auto;">
				 <table class="table">
					   <thead>
					      <tr>
					         <th>直流无功补偿系数</th>
					         <th>直流母线电压</th>
					      </tr>
					   </thead>
					   <tbody id='dataDiv3'>
					   </tbody>
					</table>
					<button type="button" class="btn btn-default" onclick="saveData(3)" style="margin: 6px 10px 0 18px;float: right;">保存  </button>
			  </div>
	   	</div>
	   	
	   	<div style="float: left;height: 40px;margin-top: 10px;padding: 6px 0px 0px 0px;">
	   		<label class="col-sm-3 control-label" style="margin: 11px 10px 0 18px;width: 97px;text-align: right;padding: 0px;"><font color="red">*</font>负荷调节系数:</label>
	   		<div class="col-sm-4" style="width: 100px;padding: 0px;">
				<input class="form-control input-sm" style="height: 35px;"  id="item1">
				
	       </div>
	   	</div>
	   	
	   	<div style="float: left;height: 40px;margin-top: 10px;padding: 8px 0px 0px 12px;">
	   		<img id="helpIcon"   src='../images/altd.png' onmouseover="intHelp(1);" onmouseout="intHelp(2);">
	   	</div>
   		<div id='helpdiv' style="position:absolute;height: 40px;padding: 8px 0px 0px 12px;width: 209px;top: 98px;left: 35%;z-index: 9999;display: none;">
			  <div class="col-lg-6" style="width: 100%;border: 1px solid #000;background-color: #eee;">
			    <div class="input-group">
			      <span>负荷调节系数: 补偿bpa的网络损耗以及华东区间联络功率的偏差(建议值: 0.8~1.2)</span>
			    </div>
			  </div>
	   	</div>
	   	
   	
   	<button class="btn btn-info btn-sm" style="position: absolute;right: 2%;margin-top: 68px;" onclick=dobpa()>bpa计算</button>
	<button class="btn btn-info btn-sm" style="position: absolute;right: 2%;margin-right: 75px;margin-top: 68px;" onclick=dopl()>转换生成  </button>
	
	<button class="btn btn-info btn-sm" style="position: absolute;right: 2%;margin-right: 155px;margin-top: 68px;" onclick=initpfo()>pfo结果  </button>
	
	<button class="btn btn-info btn-sm" style="position: absolute;right: 2%;margin-right: 229px;margin-top: 68px;" onclick=initComptable()>显示统计信息  </button>
    
    <div id='dc1' style="position: absolute;top: 100px;height: 40px;margin-top: 10px;padding: 6px 0px 0px 0px;display: none;">
   		<label class="col-sm-3 control-label" style="margin: 6px 10px 0 18px;width: 90px;text-align: right;padding: 0px;">转换dat</label>
       <button class="btn btn-info btn-sm" style="float: left;" onclick=savefiles('1')>导出</button>
       <button class="btn btn-info btn-sm" style="float: left;margin-left: 10px;" onclick=savefiles_()>保存</button>
   	</div>
   	<div id='dc2' style="position: absolute;top: 100px;right: 35%;height: 40px;margin-top: 10px;padding: 6px 0px 0px 0px;display: none;">
   		<label class="col-sm-3 control-label" style="margin: 6px 10px 0 18px;width: 90px;text-align: right;padding: 0px;">原始dat</label>
       <button class="btn btn-info btn-sm" style="float: left;" onclick=savefiles()>导出</button>
       
   	</div>
	<!-- <div id='tableTabiv' style="position:absolute;height: 90%;margin-top: 10px;padding: 8px 0px 0px 12px;width:65%;top: 10%;left: 35%;z-index: 9999;">
		<div class="col-lg-6" style="width: 100%;">
		  <ul class="nav nav-tabs" id="myTab">
		    <li class="active"><a href="#Compas1" data-toggle="tab">发电出力统计</a></li>
		    <li><a href="#Compas2" data-toggle="tab">开机容量统计</a></li>
		</ul>
		<div class="tab-content">
		    <div class="tab-pane active" id="Compas1">
				<div style="width: 100%;height: 400px;overflow-y: scroll;">
						<table id="CompasTable1" style="width: 80%;height: 400px;margin-top: 15px;margin-left: 10%;"></table>
					</div>
			</div>
		    <div class="tab-pane" id="Compas2">
				<div style="width: 100%;height: 400px;overflow-y: scroll;">
						<table id="CompasTable2" style="width: 80%;height: 400px;margin-top: 15px;margin-left: 10%;"></table>
					</div>
			</div>
		</div>
		</div>
	</div> -->
	
	
	<div id="tableTabiv" class="ui-widget-content" style="position:absolute;top: 167px;left: 38%;width: 900px;height: 600px;background:#ffffff;overflow: hidden;border:1px solid #cccccc;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;z-index: 11;display:none;">
		 <div   style="margin-top: 10px;margin-left: 20px;padding: 0 10px;font-size: 22px;font-weight: 400;">
		 	<div>统计信息</div>
  			<div class="tableTabivClose" style="position:absolute;top:10px;right:10px;width:17px;height:17px;background:url(../images/dialog_close.png) no-repeat;cursor:pointer;"></div>
		</div>
		 <div style="width: 100%;height: calc(100% - 50px);margin-top: 10px;">
			  <ul class="nav nav-tabs" id="myTab">
			    <li class="active"><a href="#Compas1" data-toggle="tab">发电出力统计</a></li>
			    <li><a href="#Compas2" data-toggle="tab">开机容量统计</a></li>
			</ul>
			<div class="tab-content" style="height: calc(100% - 42px);">
			    <div class="tab-pane active" id="Compas1">
					<table id="CompasTable1"></table>
				</div>
			    <div class="tab-pane" id="Compas2">
					<table id="CompasTable2"></table>
				</div>
			</div>
		</div>
	</div>
	
	<div id="pfodiv" class="ui-widget-content" style="position:absolute;top: 167px;left: 38%;width: 900px;height: 600px;background:#ffffff;overflow: hidden;border:1px solid #cccccc;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;z-index: 11;display:none;">
		 <div   style="margin-top: 10px;margin-left: 20px;padding: 0 10px;font-size: 22px;font-weight: 400;">
		 	<div>pfo结果</div>
  			<div class="tableTabivClose1" style="position:absolute;top:10px;right:10px;width:17px;height:17px;background:url(../images/dialog_close.png) no-repeat;cursor:pointer;"></div>
		</div>
		 <div style="width: 100%;height: 100%;margin-top: 10px;">
			  <iframe id="mainFrames" src="" frameborder="0" style="height: 99%;width: 100%;background:#F4F4F4;" ></iframe> 
		</div>
	</div>
		   	
    
    <div id="view" style="position: absolute;width: 99%;top: 160px;"></div>

    <!-- 引入组件库 -->
    <script src="codeMirror/jquery-3.2.1.min.js"></script>
    <script src="codeMirror/codemirror.js"></script>
    <script src="codeMirror/diff_match_patch.js"></script>
    <script src="codeMirror/merge.js"></script>
    <script src="codeMirror/xml.js"></script>
    <script src="codeMirror/javascript.js"></script>
    <script src="codeMirror/htmlmixed.js"></script>
	<script src="codeMirror/sublime.js"></script>
	
	<script src="codeMirror/annotatescrollbar.js"></script>
	<script src="codeMirror/matchesonscrollbar.js"></script>
	<script src="codeMirror/match-highlighter.js"></script>
	<script src="codeMirror/jump-to-line.js"></script>
	<script src="codeMirror/dialog.js"></script>
	<script src="codeMirror/searchcursor.js"></script>
	<script src="codeMirror/search.js"></script>
	
	
	<script type="text/javascript" src="../js/jquery.form.min.js"></script>
	<script type="text/javascript" src="../js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../../utils/CommonUtil.js"></script>
	<script type="text/javascript" src="../js/bootstrap-datetimepicker.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap-select.js"></script>
	<script type="text/javascript" src="../js/bootstrap-paginator.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap-treeview.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap-table.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap-table-fixed-columns.min.js"></script>
	<script type="text/javascript" src="../js/JyyLoading.js"></script>
    <script type="text/javascript">
    var value, orig1, orig2, dv, panes  , highlight = true, connect = null, collapse = false;
    var nameStr = '';
    var mrvalue ='';

    function initUI() {
		if (value == null) return;
		var target = document.getElementById("view");
		target.innerHTML = "";
		dv = CodeMirror.MergeView(target, {
			lineNumbers: true, // 显示行号
			styleActiveLine: true,//光标所在的位置代码高亮
			highlightDifferences: "highlight",//有差异的地方是否高亮
			value: value,//左边的内容（新内容）
			orig: orig2,//右边的内容（旧内容）
			lineNumbers: true,
			mode: "text/html",
			connect: connect,
			extraKeys: {'Ctrl-Q': 'autocomplete'}, //设置快捷键
			collapseIdentical: collapse,
			height:document.documentElement.clientHeight-200
		});
		//dv.edit.setSize('auto',document.documentElement.clientHeight-200);
		//dv.right.orig.setSize('auto',document.documentElement.clientHeight-200);
    }
    function initUI1() {
        var target = document.getElementById("view");
        target.innerHTML = "";
        dv = CodeMirror.MergeView(target, {
     	    lineNumbers: true, // 显示行号
			styleActiveLine: true,//光标所在的位置代码高亮
			highlightDifferences: "highlight",//有差异的地方是否高亮
			value: mrvalue,//左边的内容（新内容）
			orig: orig2,//右边的内容（旧内容）
			lineNumbers: true,
			mode: "text/html",
			connect: connect,
			extraKeys: {'Ctrl-Q': 'autocomplete'}, //设置快捷键
			collapseIdentical: collapse
		});
    }
    function choosefile () {
        var fileList = document.getElementById('dat').files;
        nameStr = '';
        for (var i = 0; i < fileList.length; i++) {
            nameStr += `${i === 0 ? '' : ', '}${fileList[i].name}`;
            var reader = new FileReader();
            reader.readAsText(fileList[i], "GB2312");
            reader.onload = function (e) {
                var content = e.target.result;
                value = content;
                orig2 = content;
                initUI();
            }
        }
    }
    function toggleDifferences() {
        dv.setShowDifferences(highlight = !highlight);
    }
    
    window.onload = function() {
		intData();
		initgetComparesData();
    	$('.dropdown-menu').click(function(e) {
    		if(e.target.textContent=='更新'|| e.target.className=='input-group-addon'||  e.target.tagName=='TD'||  e.target.tagName== 'DIV'){
    		  	e.stopPropagation();
    		}
   		});
    	/* $(this).css({"top":"45%"}); */
    	$('.tableTabivClose').click(function(){
    		$('#tableTabiv').hide();
    	});
    	$('.tableTabivClose1').click(function(){
    		$('#pfodiv').hide();
    	});
    	var div1 = document.getElementById("helpdiv");
        document.onmousemove = function (event) {
            pos (div1, 10, 20, event);
        }
    };
    function initpfo(){
		$('#pfodiv').show();
		$('#pfodiv').draggable();
		$("#mainFrames").attr('src','compares2.html');

    }
    function initComptable(){
		$('#tableTabiv').show();
		$('#tableTabiv').draggable();
		var simulaScheme = $('#simulaScheme').val();
		if(simulaScheme == "") {
			return;
		}
		var timepoint = $('#time0').val();
		if(timepoint == "") {
			return;
		}
		var timedate = $("#date0").find("input").val().replace('-','');
		if(timedate == "") {
			return;
		}
		createTable(simulaScheme,timepoint,timedate,'1');
    }
    function createTable(simulaScheme,timepoint,timedate,code) {
    	var tableid = "CompasTable"+code;
    	$.ajax({
			url: "compares/selectComparesTableData",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({projectid:simulaScheme,timepoint:timepoint,timedate:timedate,type:code}),
			contentType:"application/json",
	        success:function(tableData){
				$('#'+tableid).bootstrapTable('destroy').bootstrapTable({
			    	cache: false,
			    	fixedColumns:true,
			        fixedNumber:1,
			    	height: 505,
			        theadClasses: "bg-primary",
			    	columns: tableData.respData.columnsList,
			    	data: tableData.respData.dataList,
			    });
				var div = document.getElementById(tableid).parentNode;
				if (div.scrollWidth <= div.clientWidth) {
					div.parentNode.removeChild(div.parentNode.getElementsByClassName("fixed-columns")[0]);
				}
			}
		});
		
	}
    function intHelp(e){
    	if(e=='1'){
    		$('#helpdiv').css('display','block');
    	}else{
    		$('#helpdiv').css('display','none');
    	}
    }
    function initgetComparesData(){
    	$.ajax({
			url: "compares/getComparesData",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({}),
			contentType:"application/json",
	        success:function(data){
				data = data.respData
				var content = '';
				$("#dataDiv1").empty();
				$.each(data.list1,function(i,n){
					var vl = data.list1[i].value==undefined?"": data.list1[i].value;
					if(data.list1[i].name=='江苏') {
						content +=	`<div class="input-group">
									  <span class="input-group-addon" id="basic-addon3" style="width: 66px;font-weight: bolder;">`+data.list1[i].name+` </span>
									  <input type="text" class="form-control" id="basic-url" value=`+vl+` aria-describedby="basic-addon3">
									  <span class="input-group-btn">
								        <button class="btn btn-default" onclick="resComData(1)" type="button">更新</button>
								      </span>
									</div>`;
					}else{
						content +=	`<div class="input-group">
							  <span class="input-group-addon" id="basic-addon3" style="width: 66px;">`+data.list1[i].name+` </span>
							  <input type="text" class="form-control" id="basic-url" value=`+vl+` aria-describedby="basic-addon3">
							</div>`;
					}
				});
				content +=`<button type="button" class="btn btn-default" onclick="saveData(1)" style="margin: 6px 10px 0 18px;float: right;">保存  </button>`;
				$("#dataDiv1").append(content);
				$("#dataDiv1").selectpicker('refresh');
				
				content = '';
				$("#dataDiv2").empty();
				$.each(data.list2,function(i,n){
					var vl = data.list2[i].value==undefined?"0": data.list2[i].value;
					if(data.list2[i].name=='江苏') {
						content +=	`<div class="input-group">
									  <span class="input-group-addon" id="basic-addon3" style="width: 66px;font-weight: bolder;">`+data.list2[i].name+` </span>
									  <input type="text" class="form-control" id="basic-url" value=`+vl+` aria-describedby="basic-addon3">
									  <span class="input-group-btn">
								        <button class="btn btn-default" onclick="resComData(2)" type="button">更新</button>
								      </span>
									</div>`;
					}else{
						content +=	`<div class="input-group">
							  <span class="input-group-addon" id="basic-addon3" style="width: 66px;">`+data.list2[i].name+` </span>
							  <input type="text" class="form-control" id="basic-url" value=`+vl+` aria-describedby="basic-addon3">
							</div>`;
					}
				});
				content +=`<button type="button" class="btn btn-default" onclick="saveData(2)" style="margin: 6px 10px 0 18px;float: right;">保存  </button>`;
				$("#dataDiv2").append(content);
				$("#dataDiv2").selectpicker('refresh');
				
				content = '';
				$("#dataDiv3").empty();
				$.each(data.list3,function(i,n){
					var vl1 = data.list3[i].value==undefined?"0": data.list3[i].value;
					var vl2 = data.list4[i].value==undefined?"0": data.list4[i].value;
					if(data.list3[i].name=='直流统一配置') {
						content +=	`<tr><td><div class="input-group"><span class="input-group-addon" id="basic-addon3" style="width: 180px;font-weight: bolder;">`+data.list3[i].name+` </span>
									<input type="text" class="form-control" id="basic-url" value=`+vl1+` aria-describedby="basic-addon3">
									<span class="input-group-btn">
									<button class="btn btn-default" onclick="resComData(3)" type="button">更新</button></span></div></td><td><div class="input-group">
									  <span class="input-group-addon" id="basic-addon3" style="width: 180px;font-weight: bolder;">`+data.list4[i].name+` </span>
									  <input type="text" class="form-control" id="basic-url" value=`+vl2+` aria-describedby="basic-addon3">
									  <span class="input-group-btn">
								        <button class="btn btn-default" onclick="resComData(4)" type="button">更新</button>
								      </span>
									</div></td></tr>`;
					}else{
						content +=	`<tr><td><div class="input-group">
							  <span class="input-group-addon" id="basic-addon3" style="width: 180px;">`+data.list3[i].name+` </span>
							  <input type="text" class="form-control" id="basic-url" value=`+vl1+` aria-describedby="basic-addon3">
							</div></td><td><div class="input-group">
							  <span class="input-group-addon" id="basic-addon3" style="width: 180px;">`+data.list4[i].name+` </span>
							  <input type="text" class="form-control" id="basic-url" value=`+vl2+` aria-describedby="basic-addon3">
							</div></td></tr>`;
					}
				});

				$("#dataDiv3").append(content);
				$("#dataDiv3").selectpicker('refresh');
				
			}
		});
		
    }
    function resComData(e){
    	if(e=='1'){
	    	var t= $("#dataDiv1")[0].childNodes;
    		var value = $($("#dataDiv1")[0].children[0].children[1]).val();
	    	for(var i=1;i< t.length;i++){
	    		$($("#dataDiv1")[0].children[i].children[1]).val(value);
	    	}
    	}
    	if(e=='2'){
	    	var t= $("#dataDiv2")[0].childNodes;
    		var value = $($("#dataDiv2")[0].children[0].children[1]).val();
	    	for(var i=1;i< t.length;i++){
	    		$($("#dataDiv2")[0].children[i].children[1]).val(value);
	    	}
    	}
    	if(e=='3'){
	    	var t= $("#dataDiv3")[0].childNodes;
    		var value = $($("#dataDiv3")[0].childNodes[0].firstChild.firstChild.children[1]).val();
	    	for(var i=1;i< t.length;i++){
	    		$($("#dataDiv3")[0].childNodes[i].firstChild.firstChild.children[1]).val(value);
	    	}
    	}
    	if(e=='4'){
	    	var t= $("#dataDiv3")[0].childNodes;
    		var value = $($("#dataDiv3")[0].childNodes[0].lastChild.lastChild.children[1]).val();
	    	for(var i=1;i< t.length;i++){
	    		$($("#dataDiv3")[0].childNodes[i].lastChild.lastChild.children[1]).val(value);
	    	}
    	}
    }
    function saveData(e){
    	if(e=='1'){
	    	var t= $("#dataDiv1")[0].childNodes;
			var l = [];
	    	for(var i=0;i< t.length;i++){
	    		var name= $($("#dataDiv1")[0].children[i].children[0]).text().trim();
	    		var value = $($("#dataDiv1")[0].children[i].children[1]).val();
	    		var dl = {"name":name,"value":value};
	    		l.push(dl);
	    	}
	    	$.ajax({
				url: "compares/saveCompDatas",
				type:'POST',
				cache:false,
				async:true,
				dataType: "json",
				data: JSON.stringify({dataList:l,type:'1'}),
				contentType:"application/json",
		        success:function(data){
	                alert('保存成功');
				}
			});

    	}
    	if(e=='2'){
	    	var t= $("#dataDiv1")[0].childNodes;
			var l = [];
	    	for(var i=0;i< t.length;i++){
	    		var name= $($("#dataDiv2")[0].children[i].children[0]).text().trim();
	    		var value = $($("#dataDiv2")[0].children[i].children[1]).val();
	    		var dl = {"name":name,"value":value};
	    		l.push(dl);
	    	}
	    	$.ajax({
				url: "compares/saveCompDatas",
				type:'POST',
				cache:false,
				async:true,
				dataType: "json",
				data: JSON.stringify({dataList:l,type:'2'}),
				contentType:"application/json",
		        success:function(data){
	                alert('保存成功');
				}
			});
    	         
    	}
    	if(e=='3'){
	    	var t= $("#dataDiv3")[0].childNodes;
			var l = [];
	    	for(var i=0;i< t.length;i++){
	    		var name=$($("#dataDiv3")[0].childNodes[i].firstChild.firstChild.children[0]).text().trim();
	    		var value = $($("#dataDiv3")[0].childNodes[i].firstChild.firstChild.children[1]).val();
	    		var dl = {"name":name,"value":value};
	    		l.push(dl);
	    	}
	    	$.ajax({
				url: "compares/saveCompDatas",
				type:'POST',
				cache:false,
				async:true,
				dataType: "json",
				data: JSON.stringify({dataList:l,type:'3'}),
				contentType:"application/json",
		        success:function(data){
				}
			});
	    	
	    	var t= $("#dataDiv3")[0].childNodes;
			var l = [];
	    	for(var i=0;i< t.length;i++){
	    		var name=$($("#dataDiv3")[0].childNodes[i].lastChild.lastChild.children[0]).text().trim();
	    		var value = $($("#dataDiv3")[0].childNodes[i].lastChild.lastChild.children[1]).val();
	    		var dl = {"name":name,"value":value};
	    		l.push(dl);
	    	}
	    	$.ajax({
				url: "compares/saveCompDatas",
				type:'POST',
				cache:false,
				async:true,
				dataType: "json",
				data: JSON.stringify({dataList:l,type:'4'}),
				contentType:"application/json",
		        success:function(data){
	                alert('保存成功');
				}
			});
    	         
    	}
    }
    function mergeViewHeight(mergeView) {
      function editorHeight(editor) {
        if (!editor) return ;
        return editor.getScrollInfo().height;
      }
      return Math.max(editorHeight(mergeView.leftOriginal()),
                      editorHeight(mergeView.editor()),
                      editorHeight(mergeView.rightOriginal()));
    }
     
    function resize(mergeView) {
      var height = mergeViewHeight(mergeView);
      for(;;) {
        if (mergeView.leftOriginal())
          mergeView.leftOriginal().setSize(null, height);
        mergeView.editor().setSize(null, height);
        if (mergeView.rightOriginal())
          mergeView.rightOriginal().setSize(null, height);
     
        var newHeight = mergeViewHeight(mergeView);
        if (newHeight >= height) break;
        else height = newHeight;
      }
      mergeView.wrap.style.height = height + "px";
    }
    function intData(){
    	$.ajax({
			url: "compares/getCompDatas",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({userId:'0',modelId:'0'}),
			contentType:"application/json",
	        success:function(data){
				var content = '';
				$("#simulaScheme").empty();
				const list = data.respData.compData
				$.each(list,function(i,n){
					if(i == 0 || (i!=0 && n.projectId!=list[i-1].projectId)) {
						if(i!=0){
							content += "</optgroup>";
						}
						content += "<optgroup label='" + n.projectName + "'>";
					}
					content += "<option value='" + n.planCode + "'>"+ n.planName+"</option>";
				});
				$("#simulaScheme").append(content+"</optgroup>");
				$("#simulaScheme").selectpicker('refresh');
			}
		});
    	var option = "";
    	for(var i = 1;i <= 24;i++) {
			option += "<option value='"+i+"'>"+i+"</option>";
		}
    	$('#date0').datetimepicker({
	        format:"mm-dd",minView:2,maxView:3,startView:2,autoclose:1,language: 'cn',pickerPosition:'top-right',
	        pickerPosition: 'botom-right',
	    });
    	$("#time0").append(option);
		$("#time0").selectpicker('refresh');
    }
    function intParams (){
    	var simulaScheme = $('#simulaScheme').val();
		if(simulaScheme == "") {
			return;
		}
		var timepoint = $('#time0').val();
		if(timepoint == "") {
			return;
		}
		var timedate = $("#date0").find("input").val().replace('-','');
		if(timedate == "") {
			return;
		}
		JyyModelLoading.start("view");
		$.ajax({
			url: "compares/getCompDatasItmes",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({projectid:simulaScheme,timepoint:timepoint,timedate:timedate}),
			contentType:"application/json",
			success:function(data){
				JyyModelLoading.end("view");
                orig2 = data.respData.datData;
                value = data.respData.datData;
                initUI();
                $('#dc1').css('display','block');
                $('#dc2').css('display','block');
                $('#item1').val(data.respData.item1);
			},
			error:function(data){
                JyyModelLoading.end("view");
			}
		});
    }
    function savefiles(e) {
    	var name = nameStr;
    	var data = dv.edit.getValue();
    	if(e=='1'){
    		name = nameStr.substr(0,nameStr.length-4)+'_转换.dat';
    		ata = data;
    	}else{
    		name = nameStr.substr(0,nameStr.length-4)+'_原始.dat';
    		ata = orig2;
    	}
    	
        //Blob为js的一个对象，表示一个不可变的, 原始数据的类似文件对象，这是创建文件中不可缺少的！
      var urlObject = window.URL || window.webkitURL || window;
      var export_blob = new Blob([ata]);
      var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
      save_link.href = urlObject.createObjectURL(export_blob);
      save_link.download = name;
      save_link.click();
    }
    function savefiles_(e) {
    	JyyModelLoading.start("view");
    	var dataText = dv.edit.getValue();
   		 $.ajax({
			url: "../g/service/Sample/saveDatDataText", //后端找不到这个接口
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({dataText:dataText}),
			contentType:"application/json",
	        success:function(data){
	        	JyyModelLoading.end("view");
			},
			error:function(data){
               JyyModelLoading.end("view");
			}
		});
    }
   
    function dopl(){
    	var simulaScheme = $('#simulaScheme').val();
		if(simulaScheme == "") {
			return;
		}
		var timepoint = $('#time0').val();
		if(timepoint == "") {
			return;
		}
		var timedate = $("#date0").find("input").val().replace('-','');
		if(timedate == "") {
			return;
		}
		var item1 = $('#item1').val();
		if(item1 == "") {
			return;
		}
		JyyModelLoading.start("view","正在转换生成，请稍候...");
    	$.ajax({
			url: "compares/doCompDatas",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({projectid:simulaScheme,timepoint:timepoint,timedate:timedate,item1:item1}),
			contentType:"application/json",
	        success:function(data){
	        	value = data.datavalue;
                initUI();
                JyyModelLoading.end("view");
			},
			error:function(data){
                JyyModelLoading.end("view");
			}
		});
    }
    function dobpa(){
		JyyModelLoading.start("view","正在BPA计算，请稍候...");
    	$.ajax({
			url: "compares/doCompPFODatas",
			type:'POST',
			cache:false,
			async:true,
			dataType: "json",
			data: JSON.stringify({}),
			contentType:"application/json",
	        success:function(data){
	        	initpfo();
                JyyModelLoading.end("view");
			},
			error:function(data){
                JyyModelLoading.end("view");
			}
		});
    }
	function inportDat (){
		var fileInput = $('#dat').get(0).files[0];
		if(fileInput == undefined) {
			alert("请选择文件")
			return;
		}	
        let formDateObj = new FormData();
        formDateObj.append('file', fileInput);
        JyyModelLoading.start("view","正在更新DAT文件，请稍候...");
		$.ajax({
			type:"POST",
			url:"compares/impDatToOracleTurn",
			cache:false,
			async:true,
			data: formDateObj,
			contentType:false,
			processData:false,
			success:function(data){
				JyyModelLoading.end("view");
			},
			error:function(data){
                JyyModelLoading.end("view");
			}
		});
	}
	
	 function pos(o, x, y, event) {  //鼠标定位赋值函数
	    var posX = 0, posY = 0;  //临时变量值
	    var e = event || window.event;  //标准化事件对象
	    if (e.pageX || e.pageY) {  //获取鼠标指针的当前坐标值
	        posX = e.pageX;
	        posY = e.pageY;
	    } else if (e.clientX || e.clientY) {
	        posX = event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
	        posY = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	    }
	    o.style.position = "absolute";  //定义当前对象为绝对定位
	    o.style.top = (posY + y) + "px";  //用鼠标指针的y轴坐标和传入偏移值设置对象y轴坐标
	    o.style.left = (posX + x) + "px";  //用鼠标指针的x轴坐标和传入偏移值设置对象x轴坐标
	}
    </script>
</article>
</body>
</html>
